package com.itheima.stargraph.exception;

import cn.hutool.http.HttpStatus;
import com.itheima.stargraph.dto.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @Author mr.wu
 * @Date 2025-6-9 14:31
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    @ExceptionHandler(value = Exception.class)
    public Result exeptionCatch(Exception e) {
        log.error("发生异常，异常：", e);
        return Result.error(HttpStatus.HTTP_INTERNAL_ERROR,e.getMessage());
    }
}
